refact and cleanup