bug fix and manual refinment