New functions (thanks to Marcelo Almeida)