got part of function working