implementation of functions