working code - only tested inhandlers