seperated implementation and testing code