first attempt at writing functions