Refactored some code to fix problem removig hidden markers