fixed duplicated part of code