cleanup and implemented creation of multiple masks