Fix/495 refactoring code resolves #495