refactor and fix block breaking bug