updated conditional check on visible dynamic layers; fixed missing semicolon