Fixed some errors in ifs and maid code a little more DRY