correct use of apply functions
cleanup