refactor code to check variable == '' or not