Refactor code and assume more variables instead of requiring arguments