Code refactoring
Fixed wrong behaviour in Firefox