Refactor code to be a little bit simpler