fixed bug in readMessages and adding listener to on show of tabs