Use function calls instead of IFs(thanks to mrfyda)