Splited a function up to 2 serpate ones.