converting some macro functions to real functions