wrote the function outside of if/else