better way to define functions