Some part of this code needs to be merged with the current one