UPDATE: refactor, for better understanding =P