Re-wrote MAS listener according to Stalker's code