improve and debug