Re-write masca() function

Signed-off-by: Hector Acosta <hector.acosta@gmail.com>