refactored masks and added border feature