use bitwise and in mouse handler