Simplify the code and make it less error prone. Signed-off-by: Pranav Patil <pranavppatil767@gmail.com> Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>