added inline functions for a small speedup