castom memory allocation for handlers implemented