Guard and some refactorings